import  { useState, useEffect } from "react";
import { Button, Card } from "antd";
import dayjs from "dayjs";
import "../style/MerchantInfo.css"
import { addMerchantInfo } from "../api/merchant"
import MerchantForm from '@/pages/merchant/components/MerchantForm';
import { useNavigate } from "react-router-dom";
const MerchantInfo = () => {
    let navigate = useNavigate()
    //定义表单数据
    let [form, setForm] = useState({
        code: dayjs(Date.now()).format("YYYYMMDDHHmmssm"),
        name: "",
        merchant: "",
        phone: "",
        address: "",
        uploadUrl: "",
    });



    useEffect(() => {
    })
    //提交商户信息
    let submitData =  () => {
        addMerchantInfo(form).then(() => {
            navigate("/merchant-list")
        })
    }
    return (
        <div>

            <Card className='m-auto  w-[90%] rounded-none p-0 m-t-8'>
                <MerchantForm form={form} setForm={setForm}></MerchantForm>
                <div className="ml-80">
                    <Button type='primary' onClick={()=>{
                        submitData()
                    }}>提交</Button>
                </div>
            </Card>
        </div>
    );
};

export default MerchantInfo;